
cmake_minimum_required(VERSION 3.4.1)
# cmakelists 设置c++11
#include(CheckCXXCompilerFlag)
#CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
#CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
#if (COMPILER_SUPPORTS_CXX11)
#    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#elseif (COMPILER_SUPPORTS_CXX0X)
#    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
#else ()
#    message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
#
#endif ()

# cmakelists 设置c++11

#源码树的顶层路径。
#set(distribution_DIR ${PROJECT_SOURCE_DIR}/src/libs)
#set(distribution_DIR ${PROJECT_SOURCE_DIR}/src/main/jniLibs)
#需要编译的文件 组
#file(GLOB my_source src/main/cpp/*.cpp src/main/cpp/*.c src/main/cpp/soundtouch/SoundTouch/*.cpp)

#打印当前 cmakeLists 的路径
message("当前cmakel路径: ${CMAKE_SOURCE_DIR} \n cpu架构：${CMAKE_ANDROID_ARCH_ABI}")

# 查看gradle Console 调试信息 PROJECT_SOURCE_DIR => E:/Codes/android_code/TPlayer/ffmpeg
message(STATUS "========> distribution_DIR   is :${distribution_DIR}")
message(STATUS "========> ANDROID_ABI is : ${ANDROID_ABI}")
message(STATUS "========> the PROJECT_SOURCE_DIR is : ${PROJECT_SOURCE_DIR}")
message(STATUS "========> the PROJECT_BINARY_DIR is : ${PROJECT_BINARY_DIR}")
message(STATUS "========> the cmakeList.txt PATH is : ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "========> distribution_DIR is : ${distribution_DIR}")

set(jniLibs ${CMAKE_SOURCE_DIR}/../jniLibs)
#set(libname learn-ffmpeg)
set(libname native-lib)


include_directories(
        include
        LogUtil.h
        ${CMAKE_SOURCE_DIR}/soundtouch/include
        ${CMAKE_SOURCE_DIR}/soundtouch/SoundTouch
)

link_directories(
        ${jnilibs}/${ANDROID_ABI})

#找到包含所有的cpp文件
file(GLOB my_source *.cpp *.c)
#include_directories(soundtouch/include)
#include_directories(soundtouch/SoundTouch)
add_library( # Sets the name of the library.
        ${libname}
        SHARED
        ${my_source}
        )

#设置ffmpeg动态库
set(third-party-libs

        avcodec
        avdevice
        avfilter
        avformat
        avutil
        postproc
        swresample
        swscale
        )


#找到系统的已经存在的动态库
find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log

        )


target_link_libraries( # Specifies the target library.
        ${libname}

        ${third-party-libs}
        OpenSLES
        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})